﻿using System;

namespace Pro2
{
    class Data
    {
        public string ID { set; get; }
        public double X { set; get; }
        public double Y { set; get; }
        public double Y_general { set; get; }
        public override string ToString()
        {
            return base.ToString();
        }
    }

    enum EllipsoidType
    {
        KRASOVSKI = 1,
        IUGG1975 = 2,
        CGCS2000 = 3
    }

    class Ellipsoid
    {
        public double a { private set; get; }
        public double e_square { private set; get; }
        public double e1_square { private set; get; }

        public Ellipsoid()
        {
            a = 0;
            e_square = 0;
            e1_square = 0;
        }

        public Ellipsoid(EllipsoidType type)
        {
            SetEllipsoidType(type);
        }

        public void SetEllipsoidType(EllipsoidType type)
        {
            switch (type)
            {
                case EllipsoidType.KRASOVSKI:
                    a = 6378245.0;
                    e_square = 0.00669342162297;
                    e1_square = 0.00673852541468;
                    break;
                case EllipsoidType.IUGG1975:
                    a = 6378140.0;
                    e_square = 0.00669438499959;
                    e1_square = 0.00673950181947;
                    break;
                case EllipsoidType.CGCS2000:
                    a = 6378137.0;
                    e_square = 0.00669438002290;
                    e1_square = 0.00673949677548;
                    break;
            }
        }

        public double ComputeW(double B)
        {
            return Math.Sqrt(1 - e_square * Math.Pow(Math.Sin(B), 2));
        }

        public double ComputeEta(double B)
        {
            return Math.Sqrt(e1_square) * Math.Cos(B);
        }

        public double ComputeT(double B)
        {
            return Math.Tan(B);
        }

        public double ComputeN(double B)
        {
            double W = ComputeW(B);
            double N = a / W;
            return N;
        }

        public double ComputeM(double B)
        {
            double W = ComputeW(B);
            double M = a * (1 - e_square) / Math.Pow(W, 3);
            return M;
        }

        public double M0
        {
            get 
            {
                return a * (1 - e_square);
            }
        }

    }
}
